<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="UTF-8">
    <title>题库管理</title>
    <!--图标-->
    <link rel="shortcut icon" href="../../static/favicon.ico" th:href="@{/static/favicon.ico}">
    <link href="../../static/css/bootstrap.min.css?v=3.3.6" th:href="@{/static/css/bootstrap.min.css}" rel="stylesheet">
    <link href="../../static/css/font-awesome.css?v=4.4.0" th:href="@{/static/css/font-awesome.css}" rel="stylesheet">
    <link href="../../static/css/plugins/bootstrap-table/bootstrap-table.min.css"
          th:href="@{/static/css/plugins/bootstrap-table/bootstrap-table.min.css}" rel="stylesheet">
    <link href="../../static/css/animate.css" th:href="@{/static/css/animate.css}" rel="stylesheet">
    <link href="../../static/css/style.css?v=4.1.0" th:href="@{/static/css/style.css}" rel="stylesheet">
    <!--滑动checkbox-->
    <link href="../../static/css/plugins/switchery/switchery.css"
          th:href="@{/static/css/plugins/switchery/switchery.css}"
          rel="stylesheet">
    <!-- Sweet Alert -->
    <link href="../../static/css/plugins/sweetalert/sweetalert.css"
          th:href="@{/static/css/plugins/sweetalert/sweetalert.css}" rel="stylesheet">
    <link href="../../static/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css"
          th:href="@{/static/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css}"
          rel="stylesheet">
    <style type="text/css">
        .input_margin {
            margin-left: 20px;
        }

        .table > thead > tr > th {
            color: #2a62bc;
        }

        .tm-tab-body {
            background: #FFF;
            padding: 0 15px 15px 15px;
        }

        .tm-table-form-base-title {
            font-size: 14px;
            text-align: left;
            color: #666;
            font-weight: bold;
            line-height: 20px;
            padding: 10px 10px;
            background: #f5f5f5;
            margin: 0 0;
        }

        .tm_table_form_base_body {
            border: solid 1px #f5f5f5;
            padding: 10px 0 10px 0;
            border-top: none;
            margin: 0 0 20px 0;
        }

        .twm_desc {
            font-size: 12px;
            line-height: 20px;
            margin: 0 0;
        }

        /*模态框字体*/
        .tm_table_form_base_title {
            font-size: 14px;
            text-align: left;
            color: #666;
            font-weight: bold;
            line-height: 20px;
            padding: 10px 10px;
            background: #f5f5f5;
            margin: 0 0;
        }

        /*模态框批量导入*/
        .tm_table_form_base_body {
            border: solid 1px #f5f5f5;
            padding: 10px 0 10px 0;
            border-top: none;
            margin: 0 0 20px 0;
        }

        .tm_table_form_base {
            border-collapse: collapse; /*属性设置表格的边框是否被合并为一个单一的边框*/
            border: none;
        }

        .form-inline .input-group > .form-control {
            width: auto;
        !important;
        }

        .sweet-alert h2 {
            font-size: 18px;
        }

        .margin_bottom {
            margin-bottom: 5px;
        }

        .padding_left {
            padding-left: 40px;
        }
    </style>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox-title">
        <div class="row row-lg">
            <div class="col-sm-12">
                <div class="tabs-container">
                    <ul class="nav nav-tabs">
                        <li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true" id="message">我的题库</a>
                        </li>
                        <li class=""><a data-toggle="tab" href="#tab-2" aria-expanded="false"
                                        id="class_resource">共享题库</a></li>
                    </ul>
                    <div class="tab-content">
                        <div id="tab-1" class="tab-pane active">
                            <div class="panel-body" style="padding-bottom: 0">
                                <p style="color: #aaa" id="regulate">题库用于对试题进行分类管理，请在以下列表中管理您的题库</p>
                                <p style="color: #aaa" id="create" class="hidden">填写下面的表单，创建一个新的题库</p>
                                <p style="color: #aaa" id="update" class="hidden">在下面的表单中修改题库信息</p>

                                <div class="btn-group" style="margin-bottom: 15px">
                                    <a class="btn btn-sm btn-white create_question">创建题库</a>
                                    <a class="btn btn-sm  btn-success test_base_management"
                                       style="margin-left: 3px;">题库管理</a>
                                </div>
                                <form class="form-inline" style="margin-bottom:15px;" id="create_question">
                                    <div style="margin-bottom: 20px">
                                        <div class="form-group">
                                            <div class="input-group">
                                                <input class="form-control" type="text" placeholder="关键字"
                                                      id="queryKey" maxlength="30">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <div class="input-group">
                                                <select class="form-control" id="queryStatus">
                                                    <option value="">状态</option>
                                                    <option value="1">正常</option>
                                                    <option value="0">禁用</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <div class="input-group">
                                                <select class="form-control" id="querySecurity">
                                                    <option value="">权限</option>
                                                    <option value="1">完全私有</option>
                                                    <option value="2">只读共享</option>
                                                </select>
                                            </div>
                                        </div>
                                        <button type="button" class="btn btn-success fa fa-search"
                                                value="查询" style="height: 34px"
                                                id="queryBtn">
                                        </button>
                                    </div>
                                    <table id="tb_departments_1"></table>
                                </form>
                                <!--题库管理-->
                                <div id="test_base_management" style="display:none;">
                                    <div class="tm-tab-body" style="padding-left: 0;">
                                        <h1 class="tm-table-form-base-title">创建题库</h1>
                                        <div class="tm_table_form_base_body">
                                            <form method="get" class="form-horizontal">
                                                <div class="form-group">
                                                    <label class="col-sm-1 col-sm-offset-1 control-label">题库名称</label>
                                                    <div class="col-sm-6">
                                                        <input type="text" class="form-control" id="addName">
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-sm-1 col-sm-offset-1 control-label">题库状态</label>
                                                    <div class="col-sm-6">
                                                        <div class="radio radio-success radio-inline">
                                                            <input type="radio" id="inlineRadio1"
                                                                   value="option1" name="addStatus"
                                                                   checked="">
                                                            <label for="inlineRadio1">正常</label>
                                                        </div>
                                                        <div class="radio radio-danger radio-inline">
                                                            <input type="radio" id="inlineRadio2"
                                                                   value="option2" name="addStatus">
                                                            <label for="inlineRadio2">禁用</label>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-sm-1 col-sm-offset-1 control-label">
                                                        题库说明</label>
                                                    <div class="col-sm-6">
                                                        <textarea type="text" class="form-control" id="addNotes"></textarea>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-sm-1 col-sm-offset-1 control-label">访问权限</label>
                                                    <div class="col-sm-6">
                                                        <select class="form-control" id="addOption">
                                                            <option value="1">完全私有(只有您本人可以操作和使用题库)</option>
                                                            <option value="2">只读共享(其他管理员仅可引用您题库中的试题)</option>
                                                        </select>
                                                    </div>
                                                </div>
                                                <div class="btn-group col-sm-offset-2">
                                                    <button type="button" class="btn btn-success " id="addBank">提交
                                                    </button>
                                                    <button type="reset" class="btn btn-white"
                                                            style="margin-left: 3px;">重新填写
                                                    </button>
                                                </div>
                                            </form>
                                        </div>
                                    </div>
                                </div>
                                <!--修改题库-->
                                <div id="modification" style="display:none;">
                                    <div class="tm-tab-body" style="padding-left: 0;">
                                        <h1 class="tm-table-form-base-title">修改题库</h1>
                                        <div class="tm_table_form_base_body">
                                            <form class="form-horizontal">
                                                <div class="form-group">
                                                    <label class="col-sm-1 col-sm-offset-1 control-label">题库名称</label>
                                                    <div class="col-sm-6">
                                                        <input type="text" class="form-control question_bank_name"
                                                               id="bankName">
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-sm-1 col-sm-offset-1 control-label">题库状态</label>
                                                    <div class="col-sm-6">
                                                        <div class="radio radio-success radio-inline">
                                                            <input type="radio"
                                                                   value="1" id="on" name="alterStatus"
                                                                   checked=""/>
                                                            <label for="on">正常</label>
                                                        </div>
                                                        <div class="radio radio-danger radio-inline">
                                                            <input type="radio"
                                                                   value="0" id="off" name="alterStatus">
                                                            <label for="off">禁用</label>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-sm-1 col-sm-offset-1 control-label">
                                                        题库说明</label>
                                                    <div class="col-sm-6">
                                                        <textarea type="text"
                                                                  class="form-control explanatoryNotes"
                                                                  id="notes"></textarea>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-sm-1 col-sm-offset-1 control-label">访问权限</label>
                                                    <div class="col-sm-6">
                                                        <select class="form-control" id="alterOption">
                                                            <option class="private" value="1">完全私有(只有您本人可以操作和使用题库)
                                                            </option>
                                                            <option class="shared" value="2">只读共享(其他管理员仅可引用您题库中的试题)
                                                            </option>
                                                        </select>
                                                    </div>
                                                </div>
                                                <div class="btn-group col-sm-offset-2">
                                                    <button type="button" class="btn btn-success" id="alterBank">提交
                                                    </button>
                                                    <button type="reset" class="btn btn-white"
                                                            style="margin-left: 3px;">重新填写
                                                    </button>
                                                </div>
                                            </form>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!--共享题库-->
                        <div id="tab-2" class="tab-pane">
                            <div class="panel-body" style="padding-bottom: 0">
                                <div id="share_question_bank_tips">
                                    <p style="color: #aaa">共享题库是由各管理员创建并<strong>&nbsp;共享&nbsp;</strong>给所有管理员使用的题库，您可以使用这些题库创建试卷、组织考试
                                    </p>
                                    <p style="color: #aaa">具备<strong>&nbsp;超级管理员&nbsp;</strong>权限的管理员，可浏览并操作其他管理员的所有题库
                                    </p>
                                </div>
                                <p id="modify_the_prompt" class="hidden" style="color: red">注意：您正在修改其他管理员创建的题库，请谨慎操作</p>
                                <form class="form-inline" id="question_bank" style="margin-bottom:15px; ">
                                    <div style="margin-bottom: 20px">
                                        <div class="form-group">
                                            <div class="input-group">
                                                <input class="form-control" type="text" placeholder="关键字"
                                                       maxlength="30" id="shareKey">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <div class="input-group">
                                                <select class="form-control" id="shareStatus">
                                                    <option value="">状态</option>
                                                    <option value="1">正常</option>
                                                    <option value="0">禁用</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <div class="input-group">
                                                <input class="form-control" type="text" placeholder="创建人" id="shareUser">
                                            </div>
                                        </div>
                                        <button type="button" class="btn btn-success fa fa-search"
                                                value="查询" style="height: 34px" id="shareQueryBtn">
                                        </button>
                                    </div>
                                    <table id="tb_departments_2"></table>
                                </form>
                                <!--共享修改-->
                                <div id="share_modification" style="display:none;">
                                    <div class="tm-tab-body" style="padding-left: 0;">
                                        <h1 class="tm-table-form-base-title">修改题库</h1>
                                        <div class="tm_table_form_base_body">
                                            <form method="get" class="form-horizontal">
                                                <div style="width:950px">
                                                    <div class="form-group">
                                                        <label class="col-sm-2 control-label">题库名称</label>
                                                        <div class="col-sm-8">
                                                            <input type="text"
                                                                   class="form-control modify_the_question_bank_name" id="shareName">
                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="col-sm-2 control-label">题库状态</label>
                                                        <div class="col-sm-8">
                                                            <label class="control-label">
                                                                <div class="radio radio-success radio-inline">
                                                                    <input type="radio"
                                                                           value="1" id="normal" name="shareStatus"
                                                                           checked="">
                                                                    <label for="normal">正常</label>
                                                                </div>
                                                            </label>&nbsp;
                                                            <label class="control-label">
                                                                <div class="radio radio-danger radio-inline">
                                                                    <input type="radio" name="shareStatus"
                                                                           value="0" id="disabled">
                                                                    <label for="disabled">禁用</label>
                                                                </div>
                                                            </label>
                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="col-sm-2 control-label">
                                                            题库说明</label>
                                                        <div class="col-sm-8">
                                                            <textarea type="text"
                                                                      class="form-control modify_the_question_bank_explanation" id="shareNote"></textarea>
                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="col-sm-2 control-label">访问权限</label>
                                                        <div class="col-sm-8">
                                                            <select class="form-control" id="shareOption">
                                                                <option class="modify_private" value="1">完全私有(只有您本人可以操作和使用题库)
                                                                </option>
                                                                <option class="modify_shared" value="2">只读共享(其他管理员仅可引用您题库中的试题)
                                                                </option>
                                                            </select>
                                                        </div>
                                                    </div>
                                                    <div class="btn-group col-sm-offset-1">
                                                        <button type="button" class="btn btn-success" id="alterShareBank">提交</button>
                                                        <button type="button" class="btn btn-white" id="return_list"
                                                                style="margin-left: 3px;">返回
                                                        </button>
                                                    </div>
                                                </div>
                                            </form>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!--导入模态框-->
<div class="modal fade" id="import" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <span class="close" data-dismiss="modal">&times;</span>
                <h3 class="modal-title">提示</h3>
            </div>
            <div class="modal-body" style="margin: 10px 20px 0 20px ">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-sm-11">
                            <h4 style="font-size: 14px;font-weight: bold;margin: 15px 0 10px 0">
                                操作说明</h4>
                            <div style="margin: 0 0 20px 0">
                                <p class="twm_desc">1、下载
                                    <a href="#" target="_blank">
                                        <u>EXcel格式模板</u>
                                    </a>
                                    文件。
                                </p>
                                <p class="twm_desc">2、请注意格式要求，一个题型一个文件，多余的单元格可留空。</p>
                                <p class="twm_desc">
                                    3、请确保EXCEL文件版本为97-2003，并请勿删除（或新增）模板文件中的列，确保文件能顺利解析。</p>
                                <p class="twm_desc">4、请核对填写日期单元格，其属性为“文本”。</p>
                                <p class="twm_desc">5、默认全局自动去重后导入，如有需要，可在表单中设置忽略重复。</p>
                            </div>
                        </div>
                        <div class="col-sm-11">
                            <h1 class="tm_table_form_base_title">批量导入</h1>
                            <div class="tm_table_form_base_body">
                                <form id="import_form" method="post">
                                    <table class="tm_table_form_base" style="width: 90%">
                                        <tbody>
                                        <tr>
                                            <th width="120" class="padding_left" style="padding-bottom: 5px;">
                                                目标题库
                                            </th>
                                            <td>
                                                <select class="form-control margin_bottom">
                                                    <option value="">请选择目标题库</option>
                                                    <option>开发题</option>
                                                    <option>编程题</option>
                                                    <option>选择题</option>
                                                </select>
                                            </td>
                                        </tr>
                                        <tr>
                                            <th class="padding_left">数据文件</th>
                                            <td>
                                                <input class="form-control margin_bottom" multiple="multiple"
                                                       type="file">
                                            </td>
                                        </tr>
                                        <tr>
                                            <th class="padding_left" style="padding-top: 5px">重复数据</th>
                                            <td>
                                                <select class="form-control" style="margin-top: 5px;">
                                                    <option value="">自动去除重复试题</option>
                                                    <option>忽略重复试题，全部导入</option>
                                                </select>
                                            </td>
                                        </tr>
                                        </tbody>
                                        <tfoot>
                                        <tr>
                                            <th></th>
                                            <td>
                                                <div style="margin-top: 20px">
                                                    <button class="btn btn-success"
                                                            data-dismiss="modal">关闭
                                                    </button>
                                                    <button class="btn btn-success">确定</button>
                                                </div>
                                            </td>
                                        </tr>
                                        </tfoot>
                                    </table>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!--导出模态框-->
<div class="modal fade" id="export" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <span class="close" data-dismiss="modal">&times;</span>
                <h3 class="modal-title">提示</h3>
            </div>
            <div class="modal-body" style="margin: 10px 20px 0 20px ">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-sm-11">
                            <h4 style="font-size: 14px;font-weight: bold;margin: 15px 0 10px 0">
                                操作说明</h4>
                            <div style="margin: 0 0 20px 0">
                                <p class="twm_desc">1、选择题库和题型，导出试题为EXCEL文档。
                                </p>
                                <p class="twm_desc">2、由于题型模板不同，所以需要分开导出。</p>
                                <p class="twm_desc">
                                    3、单次最大导出 <span style="color: red">50000</span> 题，超出的试题将被忽略。
                                </p>
                            </div>
                        </div>
                        <div class="col-sm-11">
                            <h1 class="tm_table_form_base_title">题库导出</h1>
                            <div class="tm_table_form_base_body">
                                <form id="export_form" method="post">
                                    <table class="tm_table_form_base" style="width: 90%">
                                        <tbody>
                                        <tr>
                                            <th width="120"
                                                style="padding-left: 40px;">
                                                导出题库
                                            </th>
                                            <td>
                                                <select class="form-control validate[required]"
                                                        style="margin-bottom: 10px">
                                                    <option value="">请选择需要导出的题库</option>
                                                    <option>JAVA题</option>
                                                    <option>MySQL题</option>
                                                    <option>Mybatis题</option>
                                                </select>
                                            </td>
                                        </tr>
                                        <tr>
                                            <th style="padding-left: 40px;">选择题型</th>
                                            <td>
                                                <select class="form-control validate[required]">
                                                    <option value="">请选择题型</option>
                                                    <option>单选题</option>
                                                    <option>编程题</option>
                                                </select>
                                            </td>
                                        </tr>
                                        </tbody>
                                        <tfoot>
                                        <tr>
                                            <th></th>
                                            <td>
                                                <div style="margin-top: 20px">
                                                    <button class="btn btn-success"
                                                            data-dismiss="modal">关闭
                                                    </button>
                                                    <button class="btn btn-success">确定</button>
                                                </div>
                                            </td>
                                        </tr>
                                        </tfoot>
                                    </table>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<!-- 全局js -->
<script src="../../static/js/jquery.min.js?v=2.1.4" th:src="@{/static/js/jquery.min.js(v=2.1.4)}"></script>
<script src="../../static/js/bootstrap.min.js?v=3.3.6" th:src="@{/static/js/bootstrap.min.js(v=3.3.6)}"></script>
<!-- 自定义js -->
<script src="../../static/js/content.js?v=1.0.0" th:src="@{/static/js/content.js}"></script>
<!-- Bootstrap table -->
<script src="../../static/js/plugins/bootstrap-table/bootstrap-table.min.js"
        th:src="@{/static/js/plugins/bootstrap-table/bootstrap-table.min.js}"></script>
<script src="../../static/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"
        th:src="@{/static/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js}"></script>
<script src="../../static/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"
        th:src="@{/static/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js}"></script>
<!--动态搜索-->
<script src="../../static/js/plugins/suggest/bootstrap-suggest.min.js"
        th:src="@{/static/js/plugins/suggest/bootstrap-suggest.min.js}"></script>
<!-- layerDate plugin javascript -->
<script src="../../static/js/plugins/layer/laydate/laydate.js"
        th:src="@{/static/js/plugins/layer/laydate/laydate.js}"></script>
<!-- Sweet alert -->
<script src="../../static/js/plugins/sweetalert/sweetalert.min.js"
        th:src="@{/static/js/plugins/sweetalert/sweetalert.min.js}"></script>
<!--滑动按钮-->
<script src="../../static/js/plugins/switchery/switchery.js"
        th:src="@{/static/js/plugins/switchery/switchery.js}"></script>
<!-- Prettyfile -->
<script src="../../static/js/plugins/prettyfile/bootstrap-prettyfile.js"
        th:src="@{/static/js/plugins/prettyfile/bootstrap-prettyfile.js}"></script>
<script>
    $(function () {
        /*创建题库*/
        $('.create_question').click(function () {
            $('.create_question').attr("class", "btn btn-sm btn-success create_question");
            $('#create_question').css("display", "none");
            $('.test_base_management').attr("class", "btn btn-sm btn-white test_base_management");
            $('#test_base_management').css("display", "");
            $('#regulate').attr("class", "hidden");
            $('#modification').css("display", "none");
            $('#create').attr("class", "");
            $('#update').attr("class", "hidden");
        });

        /*题库管理*/
        $('.test_base_management').click(function () {
            $('.test_base_management').attr("class", "btn btn-sm btn-success test_base_management");
            $('#test_base_management').css("display", "none");
            $('.create_question').attr("class", "btn btn-sm btn-white create_question");
            $('#create_question').css("display", "");
            $('#create_question').attr("class", "form-inline");

            $('#modification').css("display", "none");
            //
            $('#regulate').attr("class", "");
            $('#create').attr("class", "hidden");
            $('#update').attr("class", "hidden");

            /*单选框状态*/

        });

        /*共享题库修改里面的返回按钮*/
        $('#return_list').click(function () {
            $('#share_modification').css("display", "none");
            $('#modify_the_prompt').css("display", "none");
            $('#question_bank').css("display", "");
            $('#share_question_bank_tips').css("display", "");
        })
    });

    /*文件上传*/
    $('input[type="file"]').prettyFile();
</script>
<script>
    /*$(function () {
        //1.初始化Table
        var oTable = new TableInit();
        oTable.Init();
        //2.初始化Button的点击事件
        var oButtonInit = new ButtonInit();
        oButtonInit.Init();
    });*/

    $(function () {
        /*当页面加载完成时显示表格*/
        $(document).ready(function (){
            //展示所有题库
            showAllBankList('/owep/examBank/allExamBank');
            //展示共享题库
            showShareBankList('/owep/examBank/shareExamBank')
        });
        //我的题库模糊查询
        $("#queryBtn").click(function (){
            var bankName = $("#queryKey").val();
            var bankStatus = $("#queryStatus").val();
            var bankSecurity = $("#querySecurity").val();
            //执行查询
            showAllBankList('/owep/examBank/findAllByKeys?bankName='+bankName+'&bankStatus='+bankStatus+'&bankSecurity='+bankSecurity);
            $('#tb_departments_1').bootstrapTable('refresh')
        })
        //共享题库模糊查询
        $("#shareQueryBtn").click(function(){
            var bankName = $("#shareKey").val();
            var bankStatus = $("#shareStatus").val();
            var userName = $("#shareUser").val();
            showShareBankList('/owep/examBank/findShareByKeys?bankName='+bankName+'&bankStatus='+bankStatus+'&user.userName='+userName);
            $('#tb_departments_2').bootstrapTable('refresh')
        })

        function showAllBankList(url) {
            /*初始化bootstrap-table*/
            //加载之前先格式化 放在查询的时候起冲突
            $('#tb_departments_1').bootstrapTable('destroy')
            //我的题库
            $('#tb_departments_1').bootstrapTable({
                url: url,       //请求后台的URL（*）
                method: 'get',                      //请求方式（*）
                striped: true,                      //是否显示行间隔色
                pagination: true,                   //是否显示分页（*）
                queryParams: function (params) {
                    var temp = {
                        "a": 1,
                        "b": 2,
                        "limits": params.limit,
                        "offset": params.offset
                    }
                    return temp;
                },                                  //传递参数（*）
                pageNumber: 1,                       //初始化加载第一页，默认第一页
                pageSize: 5,                       //每页的记录行数（*）
                pageList: [5, 10, 15, 20],        //可供选择的每页的行数（*）
                uniqueId: "id",                     //每一行的唯一标识，一般为主键列
                onLoadSuccess: updateSwitchery,  //页面加载成功执行方法
                onPageChange: updateSwitchery,   //页面发送改变执行的方法
                columns:
                    [{
                        checkbox: true
                    }, {
                        field: 'id',
                        title: '序号',
                        align: "center",
                        visible: false
                    }, {
                        field: 'bankName',
                        title: '题库',
                        align: 'center',
                        formatter: function (value, row, index) {
                            return "<div class='text-center'><p style='color:#000;margin-bottom: 0'>" + row.bankName + "</p><p class='text-muted'>" + row.bankDesc + "</p></div>";
                        }
                    }, {
                        field: 'bankStatus',
                        title: '状态',
                        align: 'center',
                        formatter: function (value, row, index) {
                            if (value == "1") {
                                return '<input type="checkbox" name="status" class="js-switch form-control" value="' + row.id + '" checked/>';
                            }
                            return '<input type="checkbox" name="status" class="js-switch form-control" value="' + row.id + '"/>';
                        }
                    }, {
                        field: 'quesNumber',
                        align: 'center',
                        title: '试题数量',
                        formatter: function (value, row, index) {
                            let num = row.quesNumber;
                            return "<a href='testItemList' style='text-decoration: underline'>" + num + "</a>";
                        }
                    }, {
                        field: 'bankSecurity',
                        align: 'center',
                        title: '管理权限',
                        formatter: function (value, row, index) {
                            let bank = row.bankSecurity;
                            if (bank == '1') {
                                return "<span><i class='fa fa-eye'></i>&ensp;" + "完全私有" + "</span>";
                            }
                            return "<span><i class='fa fa-user-secret'></i>&ensp;" + "只读共享" + "</span>";
                        }
                    }, {
                        field: 'lastAccessTime',
                        align: 'center',
                        title: '最后修改',
                        formatter: function (value, row, index) {
                            return "<div class='text-center'><p style='color:#000;margin-bottom: 0'>" + row.userName + "</p><p class='text-muted'>" + row.lastAccessTime + "</p></div>";
                        }
                    }, {
                        field: 'operate',
                        align: 'center',
                        title: '操作',
                        width: 350,
                        formatter: function (value, row, index) {
                            //下载
                            return ['<button  class = "btn btn-white btn-sm modification" type = "button"  title="修改"> <i class="fa fa-wrench">修改</i></button>' +
                            '<button id = "" type = "button" class = "btn btn-sm  btn-white " data-toggle="modal" data-target="#import" title="导入试题"><i class="fa fa-download">导入试题</i></button>' +
                            '<button id = "" type = "button" class = "btn btn-sm  btn-white " data-toggle="modal"  data-target="#export" title="导出试题"><i class="fa fa-upload">导出试题</i></button>' +
                            '<button id = "" type = "button" class = "btn btn-sm  btn-white"  title="删除题库"><i class="fa fa-close">删除题库</i></button>'];//删除

                        },//表格中按钮  
                        events: {
                            'click button[title=删除题库]': function (e, value, row, index) {
                                // console.log(row.id);
                                swal({
                                    title: "您确定要删除这条信息吗",
                                    text: "删除后将无法恢复，请谨慎操作！",
                                    type: "warning",
                                    cancelButtonText: "取消",
                                    showCancelButton: true,
                                    confirmButtonColor: "#DD6B55",
                                    confirmButtonText: "删除",
                                    closeOnConfirm: false
                                }, function () {
                                    //TODO 发送ajax请求
                                    $.ajax({
                                        url: "/owep/examBank/delBank",
                                        "dataType": "json",
                                        "type": "post",
                                        "data": "id=" + row.id,
                                        "success": function (data) {
                                            if (data.state == 200) {
                                                swal("删除成功！", "您已经永久删除。", "success");
                                            } else {
                                                swal("删除失败！", "请检查网络。", "error");
                                            }
                                            window.location.reload();
                                        },
                                    });
                                });
                            },
                            'click button[title=修改]': function (e, value, row, index) {
                                $('.modification').attr("class", "btn btn-white modification");
                                $('#modification').css("display", "");
                                $('.test_base_management').attr("class", "btn btn-sm btn-white test_base_management");
                                $('#test_base_management').css("display", "none");
                                $('.create_question').attr("class", "btn btn-sm btn-white create_question");
                                $('#create_question').attr("class", "hidden");
                                $('#create').attr("class", "hidden");
                                $('#regulate').attr("class", "hidden");
                                $('#update').attr("class", "");
                                // TODO 回显数据
                                $('.question_bank_name').val(row.bankName);
                                $('.explanatoryNotes').val(row.bankDesc);
                                if (row.bankStatus == '0') {
                                    $('#off').prop("checked", true);
                                    $('#on').prop("checked", false);
                                } else {
                                    $('#off').prop("checked", false);
                                    $('#on').prop("checked", true);
                                }
                                if (row.bankSecurity == '2') {
                                    $('.shared').attr("selected", "selected");
                                } else {
                                    $('.private').attr("selected", "selected");
                                }
                                //点击修改发送ajax请求
                                $("#alterBank").click(function () {
                                    var id = row.id;
                                    var bankName = $("#bankName").val();
                                    var bankDesc = $("#notes").val();
                                    var bankSecurity = $("#alterOption").val();
                                    $('input[name="alterStatus"]:checked').val() == 1 ? bankStatus = 1 : bankStatus = 0;
                                    var data = new FormData();
                                    data.append("id", id)
                                    data.append("bankName", bankName);
                                    data.append("bankDesc", bankDesc);
                                    data.append("bankSecurity", bankSecurity);
                                    data.append("bankStatus", bankStatus);

                                    $.ajax({
                                        url: "/owep/examBank/alterBank",
                                        "dataType": "json",
                                        "type": "post",
                                        "data": data,
                                        "contentType": false, //不关心传输内容
                                        "processData": false, //不需要ajax 对上传数据进行处理
                                        "success": function (data) {
                                            if (data.state == 200) {
                                                alert(data.msg);
                                                window.location.reload();
                                            } else {
                                                alert(data.msg);
                                            }
                                        }
                                    })
                                });
                            }
                        }
                    }]
            });

        };

        function showShareBankList(url){
            /*初始化bootstrap-table*/
            //加载之前先格式化 放在查询的时候起冲突
            $('#tb_departments_2').bootstrapTable('destroy')
            /*共享题库*/
            $('#tb_departments_2').bootstrapTable({
                url: url,       //请求后台的URL（*）
                method: 'get',                      //请求方式（*）
                striped: true,                      //是否显示行间隔色
                pagination: true,                   //是否显示分页（*）
                queryParams: function (params) {
                    var temp = {
                        "a": 1,
                        "b": 2,
                        "limits": params.limit,
                        "offset": params.offset
                    }
                    return temp;
                },                                   //传递参数（*）
                pageNumber: 1,                       //初始化加载第一页，默认第一页
                pageSize: 2,                       //每页的记录行数（*）
                pageList: [10, 25, 50, 100],        //可供选择的每页的行数（*）
                uniqueId: "id",                     //每一行的唯一标识，一般为主键列
                onLoadSuccess: updateSwitchery,  //页面加载成功执行方法
                onPageChange: updateSwitchery,   //页面发送改变执行的方法
                columns:
                    [{
                        checkbox: true
                    }, {
                        field: 'id',
                        title: '序号',
                        align: "center"
                    }, {
                        field: 'bankName',
                        title: '题库',
                        align: 'center',
                        formatter: function (value, row, index) {
                            return "<div class='text-center'><p style='color:#000;margin-bottom: 0'>" + row.bankName + "</p><p class='text-muted'>" + row.bankDesc + "</p></div>";
                        }
                    }, {
                        field: 'bankStatus',
                        title: '状态',
                        align: 'center',
                        formatter: function (value, row, index) {
                            if (value == "1") {
                                return '<input type="checkbox" name="status" class="js-switch form-control" value="' + row.id + '" checked/>';
                            }
                            return '<input type="checkbox" name="status" class="js-switch form-control" value="' + row.id + '"/>';
                        }
                    },  {
                        field: 'quesNumber',
                        align: 'center',
                        title: '试题数量',
                        formatter: function (value, row, index) {
                            let num = row.quesNumber;
                            return "<a href='testItemList.html' style='text-decoration: underline'>" + num + "</a>";
                        }
                    }, {
                        field: 'bankSecurity',
                        align: 'center',
                        title: '管理权限',
                        formatter: function (value, row, index) {
                            let bank = row.bankSecurity;
                            if (bank == '1') {
                                return "<span><i class='fa fa-eye'></i>&ensp;" + "完全私有" + "</span>";
                            }
                            return "<span><i class='fa fa-user-secret'></i>&ensp;" + "只读共享" + "</span>";
                        }
                    },  {
                        field: 'lastAccessTime',
                        align: 'center',
                        title: '最后修改',
                        formatter: function (value, row, index) {
                            return "<div class='text-center'><p style='color:#000;margin-bottom: 0'>" + row.userName + "</p><p class='text-muted'>" + row.lastAccessTime + "</p></div>";
                        }
                    }, {
                        field: 'operate',
                        align: 'center',
                        title: '操作',
                        width: 200,
                        formatter: function (value, row, index) {
                            return ['<button  class = "btn btn-white btn-sm share_modification" type = "button" title="修改"> <i class="fa fa-wrench">修改</i></button>' +
                            '<button id = "" type = "button" class = "btn btn-sm  btn-white " title="删除题库"><i class="fa fa-close">删除题库</i></button>'];//删除

                        },//表格中增加按钮  
                        events: {
                            'click button[title=删除题库]': function (e, value, row, index) {
                                // console.log(row.id);
                                swal({
                                    title: "您确定要删除这条信息吗",
                                    text: "删除后将无法恢复，请谨慎操作！",
                                    cancelButtonText: "取消",
                                    type: "warning",
                                    showCancelButton: true,
                                    confirmButtonColor: "#DD6B55",
                                    confirmButtonText: "删除",
                                    closeOnConfirm: false
                                }, function () {
                                    //TODO 发送ajax请求
                                    $.ajax({
                                        url: "/owep/examBank/delBank",
                                        "dataType": "json",
                                        "type": "post",
                                        "data": "id=" + row.id,
                                        "success": function (data) {
                                            if (data.state == 200) {
                                                swal("删除成功！", "您已经永久删除。", "success");
                                            } else {
                                                swal("删除失败！", "请检查网络。", "error");
                                            }
                                            window.location.reload();
                                        },
                                    });
                                });
                            },
                            'click button[title=修改]': function (e, value, row, index) {
                                swal({
                                    title: "您正在修改由其他管理员创建的题库",
                                    text: "修改操作无法恢复，请谨慎操作！",
                                    cancelButtonText: "取消",
                                    type: "warning",
                                    showCancelButton: true,
                                    confirmButtonColor: "#DD6B55",
                                    confirmButtonText: "知道了",
                                    closeOnConfirm: true //关闭关闭窗口
                                }, function () {
                                    /*点击修改按钮,隐藏共享题库表单:*/
                                    $('#question_bank').css("display", "none");
                                    $('#share_modification').css("display", "");
                                    /*再共享题库的提示文字隐藏*/
                                    $('#share_question_bank_tips').css("display", "none");
                                    $('#modify_the_prompt').attr("class", "");
                                    $('#modify_the_prompt').css("display", "");

                                    // TODO 回显数据
                                    $('.modify_the_question_bank_name').val(row.bankName);
                                    $('.modify_the_question_bank_explanation').val(row.bankDesc);
                                    if (row.bankStatus == '0') {
                                        $('#disabled').attr("checked", "checked");
                                    } else {
                                        $('#normal').attr("checked", "checked");
                                    }
                                    if (row.bankSecurity == '2') {
                                        $('.modify_shared').attr("selected", "selected");
                                    } else {
                                        $('.modify_private').attr("selected", "selected");
                                    }
                                    //点击修改发送ajax请求
                                    $("#alterShareBank").click(function () {
                                        var id = row.id;
                                        var bankName = $("#shareName").val();
                                        var bankDesc = $("#shareNote").val();
                                        var bankSecurity = $("#shareOption").val();
                                        $('input[name="shareStatus"]:checked').val() == 1 ? bankStatus = 1 : bankStatus = 0;
                                        var data = new FormData();
                                        data.append("id", id)
                                        data.append("bankName", bankName);
                                        data.append("bankDesc", bankDesc);
                                        data.append("bankSecurity", bankSecurity);
                                        data.append("bankStatus", bankStatus);

                                        $.ajax({
                                            url: "/owep/examBank/alterBank",
                                            "dataType": "json",
                                            "type": "post",
                                            "data": data,
                                            "contentType": false, //不关心传输内容
                                            "processData": false, //不需要ajax 对上传数据进行处理
                                            "success": function (data) {
                                                if (data.state == 200) {
                                                    alert(data.msg);
                                                    window.location.reload();
                                                } else {
                                                    alert(data.msg);
                                                }
                                            }
                                        })
                                    });
                                });
                            }
                        }
                    }]
            });
        }

        //点击添加发送ajax请求
        $("#addBank").click(function () {
            var bankName = $("#addName").val();
            var bankDesc = $("#addNotes").val();
            var bankSecurity = $("#addOption").val();
            $('input[name="addStatus"]:checked').val() == 1 ? bankStatus = 1 : bankStatus = 0;
            var data = new FormData();
            data.append("bankName", bankName);
            data.append("bankDesc", bankDesc);
            data.append("bankSecurity", bankSecurity);
            data.append("bankStatus", bankStatus);

            $.ajax({
                url: "/owep/examBank/addBank",
                "dataType": "json",
                "type": "post",
                "data": data,
                "contentType": false, //不关心传输内容
                "processData": false, //不需要ajax 对上传数据进行处理
                "success": function (data) {
                    if (data.state == 200) {
                        alert(data.msg);
                        window.location.reload();
                    } else {
                        alert(data.msg);
                    }
                }
            })
        });

        //当bootstraptable的页面分页时，要及时更新 switchery组件
        function updateSwitchery(value, row, index) {
            $(".js-switch").each(function (index, element) {
                //console.log(element);
                //判断 element是否已经是 switchery 组件了
                if ($(element).attr("data-switchery") != 'true') {
                    //重新创建switchery对象
                    new Switchery(element, {size: 'normal'});
                    //绑定事件, 以 element 为参数，以便里面的代码通过 event.data 来获取此element对象，并进一步拿到id的值
                    $(element).on('change', element, function (event) {
                        //todo 发送请求到服务端，更新状态
                        var id = $(event.data).val();
                        element.checked == false ? status = '0' : status = '1'
                        $.ajax({
                            url: "/owep/examBank/alterBank",
                            "dataType": "json",
                            "type": "post",
                            "data": {"id": id, "bankStatus": status},
                            "success": function (data) {
                                if (data.state == 200) {
                                    alert(data.msg);
                                    window.location.reload();
                                } else {
                                    alert(data.msg);
                                }
                            }
                        })

                    });
                } else {
                    //console.log("已经添加过了");
                }
            });
        };

        /*//得到查询的参数
        oTableInit.queryParams = function (params) {
            var temp = {   //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                limit: params.limit,   //页面大小
                offset: params.offset,  //页码
                departmentname: $("#txt_search_departmentname").val(),
                statu: $("#txt_search_statu").val()
            };
            return temp;
        };
        return oTableInit;*/
    });

</script>
<!--滑动按钮大小控制-->
<script>
    /*滑动按钮*/
    /*modal中的滑动checkbox*/
    let elem = Array.prototype.slice.call($('.js-switch-1'));
    let switchery_update;
    elem.forEach(function (html) {
        switchery_update = new Switchery(html, {size: 'normal'});
    });

    /*更新 滑动checkbox*/
    function checkbox_table() {
        let elems = Array.prototype.slice.call($('.js-switch'));
        elems.forEach(function (html) {
            var switchery = new Switchery(html, {size: 'normal'});
        });
    }

    /*改变滑动按钮的状态*/
    function setSwitchery(switchElement, checkedBool) {
        if ((checkedBool && !switchElement.isChecked()) || (!checkedBool && switchElement.isChecked())) {
            switchElement.setPosition(true);
            switchElement.handleOnchange(true);
        }
    }

    /*根据json数据给滑动按钮设置状态*/
    function switchBox(value, row, index) {
        if (value === "正常") {
            return '<input type="checkbox" class="js-switch form-control" checked/>';
        }
        return '<input type="checkbox" class="js-switch form-control"/>';
    }

    function switchBox_1(value, row, index) {
        if (value === "正常") {
            return '<input type="checkbox" class="js-switch_1 form-control" checked/>';
        }
        return '<input type="checkbox" class="js-switch_1 form-control"/>';
    }

    /*试题数量*/
    function item_number(value, row, index) {
        let num = row.question_size;
        return "<a href='testItemList.html' style='text-decoration: underline'>" + num + "</a>";
    }

    $(function () {
        $('[data-toggle="tooltip"]').tooltip()
    });

    //清除bootstrap table边距
    $(".simditor-toolbar").removeAttr("style");
</script>
</html>